home *** CD-ROM | disk | FTP | other *** search
/ SGI Freeware 2002 November / SGI Freeware 2002 November - Disc 1.iso / dist / fw_fftw.idb / usr / freeware / info / fftw.info-3.z / fftw.info-3 (.txt)
GNU Info File  |  2002-01-08  |  50KB  |  864 lines

  1. This is Info file fftw.info, produced by Makeinfo version 1.68 from the
  2. input file fftw.texi.
  3.    This is the FFTW User's manual.
  4.    Copyright (C) 1997-1999 Massachusetts Institute of Technology
  5.    Permission is granted to make and distribute verbatim copies of this
  6. manual provided the copyright notice and this permission notice are
  7. preserved on all copies.
  8.    Permission is granted to copy and distribute modified versions of
  9. this manual under the conditions for verbatim copying, provided that the
  10. entire resulting derived work is distributed under the terms of a
  11. permission notice identical to this one.
  12.    Permission is granted to copy and distribute translations of this
  13. manual into another language, under the above conditions for modified
  14. versions, except that this permission notice may be stated in a
  15. translation approved by the Free Software Foundation.
  16. File: fftw.info,  Node: Array Dimensions for Real Multi-dimensional Transforms,  Next: Strides in In-place RFFTWND,  Prev: rfftwnd,  Up: Real Multi-dimensional Transforms Reference
  17. Array Dimensions for Real Multi-dimensional Transforms
  18. ------------------------------------------------------
  19.    The output of a multi-dimensional transform of real data contains
  20. symmetries that, in principle, make half of the outputs redundant
  21. (*note What RFFTWND Really Computes::.).  In practice, it is not
  22. possible to entirely realize these savings in an efficient and
  23. understandable format.  Instead, the output of the rfftwnd transforms is
  24. *slightly* over half of the output of the corresponding complex
  25. transform.  We do not "pack" the data in any way, but store it as an
  26. ordinary array of `fftw_complex' values.  In fact, this data is simply
  27. a subsection of what would be the array in the corresponding complex
  28. transform.
  29.    Specifically, for a real transform of dimensions n1 x n2 x ... x nd,
  30. the complex data is an n1 x n2 x ... x (nd/2+1) array of `fftw_complex'
  31. values in row-major order (with the division rounded down).  That is,
  32. we only store the lower half (plus one element) of the last dimension
  33. of the data from the ordinary complex transform.  (We could have
  34. instead taken half of any other dimension, but implementation turns out
  35. to be simpler if the last, contiguous, dimension is used.)
  36.    Since the complex data is slightly larger than the real data, some
  37. complications arise for in-place transforms.  In this case, the final
  38. dimension of the real data must be padded with extra values to
  39. accommodate the size of the complex data--two extra if the last
  40. dimension is even and one if it is odd.  That is, the last dimension of
  41. the real data must physically contain 2 * (nd/2+1) `fftw_real' values
  42. (exactly enough to hold the complex data).  This physical array size
  43. does not, however, change the *logical* array size--only nd values are
  44. actually stored in the last dimension, and nd is the last dimension
  45. passed to `rfftwnd_create_plan'.
  46. File: fftw.info,  Node: Strides in In-place RFFTWND,  Next: rfftwnd_destroy_plan,  Prev: Array Dimensions for Real Multi-dimensional Transforms,  Up: Real Multi-dimensional Transforms Reference
  47. Strides in In-place RFFTWND
  48. ---------------------------
  49.    The fact that the input and output datatypes are different for
  50. rfftwnd complicates the meaning of the `stride' and `dist' parameters
  51. of in-place transforms--are they in units of `fftw_real' or
  52. `fftw_complex' elements?  When reading the input, they are interpreted
  53. in units of the datatype of the input data.  When writing the output,
  54. the `istride' and `idist' are translated to the output datatype's
  55. "units" in one of two ways, corresponding to the two most common
  56. situations in which `stride' and `dist' parameters are useful.  Below,
  57. we refer to these "translated" parameters as `ostride_t' and `odist_t'.
  58. (Note that these are computed internally by rfftwnd; the actual
  59. `ostride' and `odist' parameters are ignored for in-place transforms.)
  60.    First, there is the case where you are transforming a number of
  61. contiguous arrays located one after another in memory.  In this
  62. situation, `istride' is `1' and `idist' is the product of the physical
  63. dimensions of the array.  `ostride_t' and `odist_t' are then chosen so
  64. that the output arrays are contiguous and lie on top of the input
  65. arrays.  `ostride_t' is therefore `1'.  For a real-to-complex
  66. transform, `odist_t' is `idist/2'; for a complex-to-real transform,
  67. `odist_t' is `idist*2'.
  68.    The second case is when you have an array in which each element has
  69. `nc' components (e.g. a structure with `nc' numeric fields), and you
  70. want to transform all of the components at once.  Here, `istride' is
  71. `nc' and `idist' is `1'.  For this case, it is natural to want the
  72. output to also have `nc' consecutive components, now of the output data
  73. type; this is exactly what rfftwnd does.  Specifically, it uses an
  74. `ostride_t' equal to `istride', and an `odist_t' of `1'.  (Astute
  75. readers will realize that some extra buffer space is required in order
  76. to perform such a transform; this is handled automatically by rfftwnd.)
  77.    The general rule is as follows.  `ostride_t' equals `istride'.  If
  78. `idist' is `1' and `idist' is less than `istride', then `odist_t' is
  79. `1'.  Otherwise, for a real-to-complex transform `odist_t' is `idist/2'
  80. and for a complex-to-real transform `odist_t' is `idist*2'.
  81. File: fftw.info,  Node: rfftwnd_destroy_plan,  Next: What RFFTWND Really Computes,  Prev: Strides in In-place RFFTWND,  Up: Real Multi-dimensional Transforms Reference
  82. Destroying a Multi-dimensional Plan
  83. -----------------------------------
  84.      #include <rfftw.h>
  85.      
  86.      void rfftwnd_destroy_plan(rfftwnd_plan plan);
  87.    The function `rfftwnd_destroy_plan' frees the plan `plan' and
  88. releases all the memory associated with it.  After destruction, a plan
  89. is no longer valid.
  90. File: fftw.info,  Node: What RFFTWND Really Computes,  Prev: rfftwnd_destroy_plan,  Up: Real Multi-dimensional Transforms Reference
  91. What RFFTWND Really Computes
  92. ----------------------------
  93.    The conventions that we follow for the real multi-dimensional
  94. transform are analogous to those for the complex multi-dimensional
  95. transform. In particular, the forward transform has a negative sign in
  96. the exponent and neither the forward nor the backward transforms will
  97. perform any normalization.  Computing the backward transform of the
  98. forward transform will multiply the array by the product of its
  99. dimensions (that is, the logical dimensions of the real data).  The
  100. forward transform is real-to-complex and the backward transform is
  101. complex-to-real.
  102.    The TeX version of this manual contains the exact definition of the
  103. n-dimensional transform RFFTWND uses.  It is not possible to display
  104. the definition on a ASCII terminal properly.
  105. File: fftw.info,  Node: Wisdom Reference,  Next: Memory Allocator Reference,  Prev: Real Multi-dimensional Transforms Reference,  Up: FFTW Reference
  106. Wisdom Reference
  107. ================
  108. * Menu:
  109. * fftw_export_wisdom::
  110. * fftw_import_wisdom::
  111. * fftw_forget_wisdom::
  112. File: fftw.info,  Node: fftw_export_wisdom,  Next: fftw_import_wisdom,  Prev: Wisdom Reference,  Up: Wisdom Reference
  113. Exporting Wisdom
  114. ----------------
  115.      #include <fftw.h>
  116.      
  117.      void fftw_export_wisdom(void (*emitter)(char c, void *), void *data);
  118.      void fftw_export_wisdom_to_file(FILE *output_file);
  119.      char *fftw_export_wisdom_to_string(void);
  120.    These functions allow you to export all currently accumulated
  121. `wisdom' in a form from which it can be later imported and restored,
  122. even during a separate run of the program. (*Note Words of Wisdom::.)
  123. The current store of `wisdom' is not affected by calling any of these
  124. routines.
  125.    `fftw_export_wisdom' exports the `wisdom' to any output medium, as
  126. specified by the callback function `emitter'. `emitter' is a
  127. `putc'-like function that writes the character `c' to some output; its
  128. second parameter is the `data' pointer passed to `fftw_export_wisdom'.
  129. For convenience, the following two "wrapper" routines are provided:
  130.    `fftw_export_wisdom_to_file' writes the `wisdom' to the current
  131. position in `output_file', which should be open with write permission.
  132. Upon exit, the file remains open and is positioned at the end of the
  133. `wisdom' data.
  134.    `fftw_export_wisdom_to_string' returns a pointer to a
  135. `NULL'-terminated string holding the `wisdom' data. This string is
  136. dynamically allocated, and it is the responsibility of the caller to
  137. deallocate it with `fftw_free' when it is no longer needed.
  138.    All of these routines export the wisdom in the same format, which we
  139. will not document here except to say that it is LISP-like ASCII text
  140. that is insensitive to white space.
  141. File: fftw.info,  Node: fftw_import_wisdom,  Next: fftw_forget_wisdom,  Prev: fftw_export_wisdom,  Up: Wisdom Reference
  142. Importing Wisdom
  143. ----------------
  144.      #include <fftw.h>
  145.      
  146.      fftw_status fftw_import_wisdom(int (*get_input)(void *), void *data);
  147.      fftw_status fftw_import_wisdom_from_file(FILE *input_file);
  148.      fftw_status fftw_import_wisdom_from_string(const char *input_string);
  149.    These functions import `wisdom' into a program from data stored by
  150. the `fftw_export_wisdom' functions above. (*Note Words of Wisdom::.)
  151. The imported `wisdom' supplements rather than replaces any `wisdom'
  152. already accumulated by the running program (except when there is
  153. conflicting `wisdom', in which case the existing wisdom is replaced).
  154.    `fftw_import_wisdom' imports `wisdom' from any input medium, as
  155. specified by the callback function `get_input'. `get_input' is a
  156. `getc'-like function that returns the next character in the input; its
  157. parameter is the `data' pointer passed to `fftw_import_wisdom'. If the
  158. end of the input data is reached (which should never happen for valid
  159. data), it may return either `NULL' (ASCII 0) or `EOF' (as defined in
  160. `<stdio.h>').  For convenience, the following two "wrapper" routines
  161. are provided:
  162.    `fftw_import_wisdom_from_file' reads `wisdom' from the current
  163. position in `input_file', which should be open with read permission.
  164. Upon exit, the file remains open and is positioned at the end of the
  165. `wisdom' data.
  166.    `fftw_import_wisdom_from_string' reads `wisdom' from the
  167. `NULL'-terminated string `input_string'.
  168.    The return value of these routines is `FFTW_SUCCESS' if the wisdom
  169. was read successfully, and `FFTW_FAILURE' otherwise. Note that, in all
  170. of these functions, any data in the input stream past the end of the
  171. `wisdom' data is simply ignored (it is not even read if the `wisdom'
  172. data is well-formed).
  173. File: fftw.info,  Node: fftw_forget_wisdom,  Prev: fftw_import_wisdom,  Up: Wisdom Reference
  174. Forgetting Wisdom
  175. -----------------
  176.      #include <fftw.h>
  177.      
  178.      void fftw_forget_wisdom(void);
  179.    Calling `fftw_forget_wisdom' causes all accumulated `wisdom' to be
  180. discarded and its associated memory to be freed. (New `wisdom' can
  181. still be gathered subsequently, however.)
  182. File: fftw.info,  Node: Memory Allocator Reference,  Next: Thread safety,  Prev: Wisdom Reference,  Up: FFTW Reference
  183. Memory Allocator Reference
  184. ==========================
  185.      #include <fftw.h>
  186.      
  187.      void *(*fftw_malloc_hook) (size_t n);
  188.      void (*fftw_free_hook) (void *p);
  189.    Whenever it has to allocate and release memory, FFTW ordinarily calls
  190. `malloc' and `free'.  If `malloc' fails, FFTW prints an error message
  191. and exits.  This behavior may be undesirable in some applications.
  192. Also, special memory-handling functions may be necessary in certain
  193. environments. Consequently, FFTW provides means by which you can install
  194. your own memory allocator and take whatever error-correcting action you
  195. find appropriate.  The variables `fftw_malloc_hook' and
  196. `fftw_free_hook' are pointers to functions, and they are normally
  197. `NULL'.  If you set those variables to point to other functions, then
  198. FFTW will use your routines instead of `malloc' and `free'.
  199. `fftw_malloc_hook' must point to a `malloc'-like function, and
  200. `fftw_free_hook' must point to a `free'-like function.
  201. File: fftw.info,  Node: Thread safety,  Prev: Memory Allocator Reference,  Up: FFTW Reference
  202. Thread safety
  203. =============
  204.    Users writing multi-threaded programs must concern themselves with
  205. the "thread safety" of the libraries they use--that is, whether it is
  206. safe to call routines in parallel from multiple threads.  FFTW can be
  207. used in such an environment, but some care must be taken because certain
  208. parts of FFTW use private global variables to share data between calls.
  209. In particular, the plan-creation functions share trigonometric tables
  210. and accumulated `wisdom'.  (Users should note that these comments only
  211. apply to programs using shared-memory threads.  Parallelism using MPI
  212. or forked processes involves a separate address-space and global
  213. variables for each process, and is not susceptible to problems of this
  214. sort.)
  215.    The central restriction of FFTW is that it is not safe to create
  216. multiple plans in parallel.  You must either create all of your plans
  217. from a single thread, or instead use a semaphore, mutex, or other
  218. mechanism to ensure that different threads don't attempt to create plans
  219. at the same time.  The same restriction also holds for destruction of
  220. plans and importing/forgetting `wisdom'.  Once created, a plan may
  221. safely be used in any thread.
  222.    The actual transform routines in FFTW (`fftw_one', etcetera) are
  223. re-entrant and thread-safe, so it is fine to call them simultaneously
  224. from multiple threads.  Another question arises, however--is it safe to
  225. use the *same plan* for multiple transforms in parallel?  (It would be
  226. unsafe if, for example, the plan were modified in some way by the
  227. transform.)  We address this question by defining an additional planner
  228. flag, `FFTW_THREADSAFE'.  When included in the flags for any of the
  229. plan-creation routines, `FFTW_THREADSAFE' guarantees that the resulting
  230. plan will be read-only and safe to use in parallel by multiple threads.
  231. File: fftw.info,  Node: Parallel FFTW,  Next: Calling FFTW from Fortran,  Prev: FFTW Reference,  Up: Top
  232. Parallel FFTW
  233. *************
  234.    In this chapter we discuss the use of FFTW in a parallel environment,
  235. documenting the different parallel libraries that we have provided.
  236. (Users calling FFTW from a multi-threaded program should also consult
  237. *Note Thread safety::.)  The FFTW package currently contains three
  238. parallel transform implementations that leverage the uniprocessor FFTW
  239. code:
  240.    * The first set of routines utilizes shared-memory threads for
  241.      parallel one- and multi-dimensional transforms of both real and
  242.      complex data.  Any program using FFTW can be trivially modified to
  243.      use the multi-threaded routines.  This code can use any common
  244.      threads implementation, including POSIX threads.  (POSIX threads
  245.      are available on most Unix variants, including Linux.)  These
  246.      routines are located in the `threads' directory, and are
  247.      documented in *Note Multi-threaded FFTW::.
  248.    * The `mpi' directory contains multi-dimensional transforms of real
  249.      and complex data for parallel machines supporting MPI.  It also
  250.      includes parallel one-dimensional transforms for complex data.
  251.      The main feature of this code is that it supports
  252.      distributed-memory transforms, so it runs on everything from
  253.      workstation clusters to massively-parallel supercomputers.  More
  254.      information on MPI can be found at the MPI home page (http://www.mcs.anl.gov/mpi).  The FFTW MPI routines are documented in *Note MPI
  255.      FFTW::.
  256.    * We also have an experimental parallel implementation written in
  257.      Cilk, a C-like parallel language developed at MIT and currently
  258.      available for several SMP platforms.  For more information on Cilk
  259.      see the Cilk home page (http://supertech.lcs.mit.edu/cilk).  The
  260.      FFTW Cilk code can be found in the `cilk' directory, with
  261.      parallelized one- and multi-dimensional transforms of complex
  262.      data.  The Cilk FFTW routines are documented in `cilk/README'.
  263. * Menu:
  264. * Multi-threaded FFTW::
  265. * MPI FFTW::
  266. File: fftw.info,  Node: Multi-threaded FFTW,  Next: MPI FFTW,  Prev: Parallel FFTW,  Up: Parallel FFTW
  267. Multi-threaded FFTW
  268. ===================
  269.    In this section we document the parallel FFTW routines for
  270. shared-memory threads on SMP hardware.  These routines, which support
  271. parallel one- and multi-dimensional transforms of both real and complex
  272. data, are the easiest way to take advantage of multiple processors with
  273. FFTW.  They work just like the corresponding uniprocessor transform
  274. routines, except that they take the number of parallel threads to use
  275. as an extra parameter.  Any program that uses the uniprocessor FFTW can
  276. be trivially modified to use the multi-threaded FFTW.
  277. * Menu:
  278. * Installation and Supported Hardware/Software::
  279. * Usage of Multi-threaded FFTW::
  280. * How Many Threads to Use?::
  281. * Using Multi-threaded FFTW in a Multi-threaded Program::
  282. * Tips for Optimal Threading::
  283. File: fftw.info,  Node: Installation and Supported Hardware/Software,  Next: Usage of Multi-threaded FFTW,  Prev: Multi-threaded FFTW,  Up: Multi-threaded FFTW
  284. Installation and Supported Hardware/Software
  285. --------------------------------------------
  286.    All of the FFTW threads code is located in the `threads'
  287. subdirectory of the FFTW package.  On Unix systems, the FFTW threads
  288. libraries and header files can be automatically configured, compiled,
  289. and installed along with the uniprocessor FFTW libraries simply by
  290. including `--enable-threads' in the flags to the `configure' script
  291. (*note Installation on Unix::.).  (Note also that the threads routines,
  292. when enabled, are automatically tested by the ``make check''
  293. self-tests.)
  294.    The threads routines require your operating system to have some sort
  295. of shared-memory threads support.  Specifically, the FFTW threads
  296. package works with POSIX threads (available on most Unix variants,
  297. including Linux), Solaris threads, BeOS (http://www.be.com) threads
  298. (tested on BeOS DR8.2), Mach C threads (reported to work by users), and
  299. Win32 threads (reported to work by users).  (There is also untested
  300. code to use MacOS MP threads.)  If you have a shared-memory machine
  301. that uses a different threads API, it should be a simple matter of
  302. programming to include support for it; see the file
  303. `fftw_threads-int.h' for more detail.
  304.    SMP hardware is not required, although of course you need multiple
  305. processors to get any benefit from the multithreaded transforms.
  306. File: fftw.info,  Node: Usage of Multi-threaded FFTW,  Next: How Many Threads to Use?,  Prev: Installation and Supported Hardware/Software,  Up: Multi-threaded FFTW
  307. Usage of Multi-threaded FFTW
  308. ----------------------------
  309.    Here, it is assumed that the reader is already familiar with the
  310. usage of the uniprocessor FFTW routines, described elsewhere in this
  311. manual.  We only describe what one has to change in order to use the
  312. multi-threaded routines.
  313.    First, instead of including `<fftw.h>' or `<rfftw.h>', you should
  314. include the files `<fftw_threads.h>' or `<rfftw_threads.h>',
  315. respectively.
  316.    Second, before calling any FFTW routines, you should call the
  317. function:
  318.      int fftw_threads_init(void);
  319.    This function, which should only be called once (probably in your
  320. `main()' function), performs any one-time initialization required to
  321. use threads on your system.  It returns zero if successful, and a
  322. non-zero value if there was an error (in which case, something is
  323. seriously wrong and you should probably exit the program).
  324.    Third, when you want to actually compute the transform, you should
  325. use one of the following transform routines instead of the ordinary FFTW
  326. functions:
  327.      fftw_threads(nthreads, plan, howmany, in, istride,
  328.                   idist, out, ostride, odist);
  329.      
  330.      fftw_threads_one(nthreads, plan, in, out);
  331.      
  332.      fftwnd_threads(nthreads, plan, howmany, in, istride,
  333.                     idist, out, ostride, odist);
  334.      
  335.      fftwnd_threads_one(nthreads, plan, in, out);
  336.      
  337.      rfftw_threads(nthreads, plan, howmany, in, istride,
  338.                    idist, out, ostride, odist);
  339.      
  340.      rfftw_threads_one(nthreads, plan, in, out);
  341.      
  342.      rfftwnd_threads_real_to_complex(nthreads, plan, howmany, in,
  343.                                      istride, idist, out, ostride, odist);
  344.      
  345.      rfftwnd_threads_one_real_to_complex(nthreads, plan, in, out);
  346.      
  347.      rfftwnd_threads_complex_to_real(nthreads, plan, howmany, in,
  348.                                      istride, idist, out, ostride, odist);
  349.      
  350.      rfftwnd_threads_one_real_to_complex(nthreads, plan, in, out);
  351.      
  352.      rfftwnd_threads_one_complex_to_real(nthreads, plan, in, out);
  353.    All of these routines take exactly the same arguments and have
  354. exactly the same effects as their uniprocessor counterparts (i.e.
  355. without the ``_threads'') *except* that they take one extra parameter,
  356. `nthreads' (of type `int'), before the normal parameters.(1)  The
  357. `nthreads' parameter specifies the number of threads of execution to
  358. use when performing the transform (actually, the maximum number of
  359. threads).
  360.    For example, to parallelize a single one-dimensional transform of
  361. complex data, instead of calling the uniprocessor `fftw_one(plan, in,
  362. out)', you would call `fftw_threads_one(nthreads, plan, in, out)'.
  363. Passing an `nthreads' of `1' means to use only one thread (the main
  364. thread), and is equivalent to calling the uniprocessor routine.
  365. Passing an `nthreads' of `2' means that the transform is potentially
  366. parallelized over two threads (and two processors, if you have them),
  367. and so on.
  368.    These are the only changes you need to make to your source code.
  369. Calls to all other FFTW routines (plan creation, destruction, wisdom,
  370. etcetera) are not parallelized and remain the same.  (The same plans and
  371. wisdom are used by both uniprocessor and multi-threaded transforms.)
  372. Your arrays are allocated and formatted in the same way, and so on.
  373.    Programs using the parallel complex transforms should be linked with
  374. `-lfftw_threads -lfftw -lm' on Unix.  Programs using the parallel real
  375. transforms should be linked with `-lrfftw_threads -lfftw_threads
  376. -lrfftw -lfftw -lm'.  You will also need to link with whatever library
  377. is responsible for threads on your system (e.g. `-lpthread' on Linux).
  378.    ---------- Footnotes ----------
  379.    (1) There is one exception: when performing one-dimensional in-place
  380. transforms, the `out' parameter is always ignored by the multi-threaded
  381. routines, instead of being used as a workspace if it is non-`NULL' as
  382. in the uniprocessor routines.  The multi-threaded routines always
  383. allocate their own workspace (the size of which depends upon the number
  384. of threads).
  385. File: fftw.info,  Node: How Many Threads to Use?,  Next: Using Multi-threaded FFTW in a Multi-threaded Program,  Prev: Usage of Multi-threaded FFTW,  Up: Multi-threaded FFTW
  386. How Many Threads to Use?
  387. ------------------------
  388.    There is a fair amount of overhead involved in spawning and
  389. synchronizing threads, so the optimal number of threads to use depends
  390. upon the size of the transform as well as on the number of processors
  391. you have.
  392.    As a general rule, you don't want to use more threads than you have
  393. processors.  (Using more threads will work, but there will be extra
  394. overhead with no benefit.)  In fact, if the problem size is too small,
  395. you may want to use fewer threads than you have processors.
  396.    You will have to experiment with your system to see what level of
  397. parallelization is best for your problem size.  Useful tools to help you
  398. do this are the test programs that are automatically compiled along with
  399. the threads libraries, `fftw_threads_test' and `rfftw_threads_test' (in
  400. the `threads' subdirectory).  These take the same arguments as the
  401. other FFTW test programs (see `tests/README'), except that they also
  402. take the number of threads to use as a first argument, and report the
  403. parallel speedup in speed tests.  For example,
  404.      fftw_threads_test 2 -s 128x128
  405.    will benchmark complex 128x128 transforms using two threads and
  406. report the speedup relative to the uniprocessor transform.
  407.    For instance, on a 4-processor 200MHz Pentium Pro system running
  408. Linux 2.2.0, we found that the "crossover" point at which 2 threads
  409. became beneficial for complex transforms was about 4k points, while 4
  410. threads became beneficial at 8k points.
  411. File: fftw.info,  Node: Using Multi-threaded FFTW in a Multi-threaded Program,  Next: Tips for Optimal Threading,  Prev: How Many Threads to Use?,  Up: Multi-threaded FFTW
  412. Using Multi-threaded FFTW in a Multi-threaded Program
  413. -----------------------------------------------------
  414.    It is perfectly possible to use the multi-threaded FFTW routines
  415. from a multi-threaded program (e.g. have multiple threads computing
  416. multi-threaded transforms simultaneously).  If you have the processors,
  417. more power to you!  However, the same restrictions apply as for the
  418. uniprocessor FFTW routines (*note Thread safety::.).  In particular, you
  419. should recall that you may not create or destroy plans in parallel.
  420. File: fftw.info,  Node: Tips for Optimal Threading,  Prev: Using Multi-threaded FFTW in a Multi-threaded Program,  Up: Multi-threaded FFTW
  421. Tips for Optimal Threading
  422. --------------------------
  423.    Not all transforms are equally well-parallelized by the
  424. multi-threaded FFTW routines.  (This is merely a consequence of
  425. laziness on the part of the implementors, and is not inherent to the
  426. algorithms employed.)  Mainly, the limitations are in the parallel
  427. one-dimensional transforms.  The things to avoid if you want optimal
  428. parallelization are as follows:
  429. Parallelization deficiencies in one-dimensional transforms
  430. ----------------------------------------------------------
  431.    * Large prime factors can sometimes parallelize poorly.  Of course,
  432.      you should avoid these anyway if you want high performance.
  433.    * Single in-place transforms don't parallelize completely.  (Multiple
  434.      in-place transforms, i.e. `howmany > 1', are fine.)  Again, you
  435.      should avoid these in any case if you want high performance, as
  436.      they require transforming to a scratch array and copying back.
  437.    * Single real-complex (`rfftw') transforms don't parallelize
  438.      completely.  This is unfortunate, but parallelizing this correctly
  439.      would have involved a lot of extra code (and a much larger
  440.      library).  You still get some benefit from additional processors,
  441.      but if you have a very large number of processors you will
  442.      probably be better off using the parallel complex (`fftw')
  443.      transforms.  Note that multi-dimensional real transforms or
  444.      multiple one-dimensional real transforms are fine.
  445. File: fftw.info,  Node: MPI FFTW,  Prev: Multi-threaded FFTW,  Up: Parallel FFTW
  446. MPI FFTW
  447. ========
  448.    This section describes the MPI FFTW routines for distributed-memory
  449. (and shared-memory) machines supporting MPI (Message Passing
  450. Interface).  The MPI routines are significantly different from the
  451. ordinary FFTW because the transform data here are *distributed* over
  452. multiple processes, so that each process gets only a portion of the
  453. array.  Currently, multi-dimensional transforms of both real and
  454. complex data, as well as one-dimensional transforms of complex data,
  455. are supported.
  456. * Menu:
  457. * MPI FFTW Installation::
  458. * Usage of MPI FFTW for Complex Multi-dimensional Transforms::
  459. * MPI Data Layout::
  460. * Usage of MPI FFTW for Real Multi-dimensional Transforms::
  461. * Usage of MPI FFTW for Complex One-dimensional Transforms::
  462. * MPI Tips::
  463. File: fftw.info,  Node: MPI FFTW Installation,  Next: Usage of MPI FFTW for Complex Multi-dimensional Transforms,  Prev: MPI FFTW,  Up: MPI FFTW
  464. MPI FFTW Installation
  465. ---------------------
  466.    The FFTW MPI library code is all located in the `mpi' subdirectoy of
  467. the FFTW package (along with source code for test programs).  On Unix
  468. systems, the FFTW MPI libraries and header files can be automatically
  469. configured, compiled, and installed along with the uniprocessor FFTW
  470. libraries simply by including `--enable-mpi' in the flags to the
  471. `configure' script (*note Installation on Unix::.).
  472.    The only requirement of the FFTW MPI code is that you have the
  473. standard MPI 1.1 (or later) libraries and header files installed on
  474. your system.  A free implementation of MPI is available from
  475. the MPICH home page (http://www-unix.mcs.anl.gov/mpi/mpich/).
  476.    Previous versions of the FFTW MPI routines have had an unfortunate
  477. tendency to expose bugs in MPI implementations.  The current version has
  478. been largely rewritten, and hopefully avoids some of the problems.  If
  479. you run into difficulties, try passing the optional workspace to
  480. `(r)fftwnd_mpi' (see below), as this allows us to use the standard (and
  481. hopefully well-tested) `MPI_Alltoall' primitive for communications.
  482. Please let us know (<fftw@fftw.org>) how things work out.
  483.    Several test programs are included in the `mpi' directory.  The ones
  484. most useful to you are probably the `fftw_mpi_test' and
  485. `rfftw_mpi_test' programs, which are run just like an ordinary MPI
  486. program and accept the same parameters as the other FFTW test programs
  487. (c.f. `tests/README').  For example, `mpirun ...params...
  488. fftw_mpi_test -r 0' will run non-terminating complex-transform
  489. correctness tests of random dimensions.  They can also do performance
  490. benchmarks.
  491. File: fftw.info,  Node: Usage of MPI FFTW for Complex Multi-dimensional Transforms,  Next: MPI Data Layout,  Prev: MPI FFTW Installation,  Up: MPI FFTW
  492. Usage of MPI FFTW for Complex Multi-dimensional Transforms
  493. ----------------------------------------------------------
  494.    Usage of the MPI FFTW routines is similar to that of the uniprocessor
  495. FFTW.  We assume that the reader already understands the usage of the
  496. uniprocessor FFTW routines, described elsewhere in this manual.  Some
  497. familiarity with MPI is also helpful.
  498.    A typical program performing a complex two-dimensional MPI transform
  499. might look something like:
  500.      #include <fftw_mpi.h>
  501.      
  502.      int main(int argc, char **argv)
  503.      {
  504.            const int NX = ..., NY = ...;
  505.            fftwnd_mpi_plan plan;
  506.            fftw_complex *data;
  507.      
  508.            MPI_Init(&argc,&argv);
  509.      
  510.            plan = fftw2d_mpi_create_plan(MPI_COMM_WORLD,
  511.                                          NX, NY,
  512.                                          FFTW_FORWARD, FFTW_ESTIMATE);
  513.      
  514.            ...allocate and initialize data...
  515.      
  516.            fftwnd_mpi(p, 1, data, NULL, FFTW_NORMAL_ORDER);
  517.      
  518.            ...
  519.      
  520.            fftwnd_mpi_destroy_plan(plan);
  521.            MPI_Finalize();
  522.      }
  523.    The calls to `MPI_Init' and `MPI_Finalize' are required in all MPI
  524. programs; see the MPI home page (http://www.mcs.anl.gov/mpi/) for more
  525. information.  Note that all of your processes run the program in
  526. parallel, as a group; there is no explicit launching of
  527. threads/processes in an MPI program.
  528.    As in the ordinary FFTW, the first thing we do is to create a plan
  529. (of type `fftwnd_mpi_plan'), using:
  530.      fftwnd_mpi_plan fftw2d_mpi_create_plan(MPI_Comm comm,
  531.                                             int nx, int ny,
  532.                                             fftw_direction dir, int flags);
  533.    Except for the first argument, the parameters are identical to those
  534. of `fftw2d_create_plan'.  (There are also analogous
  535. `fftwnd_mpi_create_plan' and `fftw3d_mpi_create_plan' functions.
  536. Transforms of any rank greater than one are supported.)  The first
  537. argument is an MPI "communicator", which specifies the group of
  538. processes that are to be involved in the transform; the standard
  539. constant `MPI_COMM_WORLD' indicates all available processes.
  540.    Next, one has to allocate and initialize the data.  This is somewhat
  541. tricky, because the transform data is distributed across the processes
  542. involved in the transform.  It is discussed in detail by the next
  543. section (*note MPI Data Layout::.).
  544.    The actual computation of the transform is performed by the function
  545. `fftwnd_mpi', which differs somewhat from its uniprocessor equivalent
  546. and is described by:
  547.      void fftwnd_mpi(fftwnd_mpi_plan p,
  548.                      int n_fields,
  549.                      fftw_complex *local_data, fftw_complex *work,
  550.                      fftwnd_mpi_output_order output_order);
  551.    There are several things to notice here:
  552.    * First of all, all `fftw_mpi' transforms are in-place: the output is
  553.      in the `local_data' parameter, and there is no need to specify
  554.      `FFTW_IN_PLACE' in the plan flags.
  555.    * The MPI transforms also only support a limited subset of the
  556.      `howmany'/`stride'/`dist' functionality of the uniprocessor
  557.      routines: the `n_fields' parameter is equivalent to
  558.      `howmany=n_fields', `stride=n_fields', and `dist=1'.
  559.      (Conceptually, the `n_fields' parameter allows you to transform an
  560.      array of contiguous vectors, each with length `n_fields'.)
  561.      `n_fields' is `1' if you are only transforming a single, ordinary
  562.      array.
  563.    * The `work' parameter is an optional workspace.  If it is not
  564.      `NULL', it should be exactly the same size as the `local_data'
  565.      array.  If it is provided, FFTW is able to use the built-in
  566.      `MPI_Alltoall' primitive for (often) greater efficiency at the
  567.      expense of extra storage space.
  568.    * Finally, the last parameter specifies whether the output data has
  569.      the same ordering as the input data (`FFTW_NORMAL_ORDER'), or if
  570.      it is transposed (`FFTW_TRANSPOSED_ORDER').  Leaving the data
  571.      transposed results in significant performance improvements due to
  572.      a saved communication step (needed to un-transpose the data).
  573.      Specifically, the first two dimensions of the array are
  574.      transposed, as is described in more detail by the next section.
  575.    The output of `fftwnd_mpi' is identical to that of the corresponding
  576. uniprocessor transform.  In particular, you should recall our
  577. conventions for normalization and the sign of the transform exponent.
  578.    The same plan can be used to compute many transforms of the same
  579. size.  After you are done with it, you should deallocate it by calling
  580. `fftwnd_mpi_destroy_plan'.
  581.    Important: The FFTW MPI routines must be called in the same order by
  582. all processes involved in the transform.  You should assume that they
  583. all are blocking, as if each contained a call to `MPI_Barrier'.
  584.    Programs using the FFTW MPI routines should be linked with
  585. `-lfftw_mpi -lfftw -lm' on Unix, in addition to whatever libraries are
  586. required for MPI.
  587. File: fftw.info,  Node: MPI Data Layout,  Next: Usage of MPI FFTW for Real Multi-dimensional Transforms,  Prev: Usage of MPI FFTW for Complex Multi-dimensional Transforms,  Up: MPI FFTW
  588. MPI Data Layout
  589. ---------------
  590.    The transform data used by the MPI FFTW routines is "distributed": a
  591. distinct portion of it resides with each process involved in the
  592. transform.  This allows the transform to be parallelized, for example,
  593. over a cluster of workstations, each with its own separate memory, so
  594. that you can take advantage of the total memory of all the processors
  595. you are parallelizing over.
  596.    In particular, the array is divided according to the rows (first
  597. dimension) of the data: each process gets a subset of the rows of the
  598. data.  (This is sometimes called a "slab decomposition.")  One
  599. consequence of this is that you can't take advantage of more processors
  600. than you have rows (e.g. `64x64x64' matrix can at most use 64
  601. processors).  This isn't usually much of a limitation, however, as each
  602. processor needs a fair amount of data in order for the
  603. parallel-computation benefits to outweight the communications costs.
  604.    Below, the first dimension of the data will be referred to as ``x''
  605. and the second dimension as ``y''.
  606.    FFTW supplies a routine to tell you exactly how much data resides on
  607. the current process:
  608.      void fftwnd_mpi_local_sizes(fftwnd_mpi_plan p,
  609.                                  int *local_nx,
  610.                                  int *local_x_start,
  611.                                  int *local_ny_after_transpose,
  612.                                  int *local_y_start_after_transpose,
  613.                                  int *total_local_size);
  614.    Given a plan `p', the other parameters of this routine are set to
  615. values describing the required data layout, described below.
  616.    `total_local_size' is the number of `fftw_complex' elements that you
  617. must allocate for your local data (and workspace, if you choose).
  618. (This value should, of course, be multiplied by `n_fields' if that
  619. parameter to `fftwnd_mpi' is not `1'.)
  620.    The data on the current process has `local_nx' rows, starting at row
  621. `local_x_start'.  If `fftwnd_mpi' is called with
  622. `FFTW_TRANSPOSED_ORDER' output, then `y' will be the first dimension of
  623. the output, and the local `y' extent will be given by
  624. `local_ny_after_transpose' and `local_y_start_after_transpose'.
  625. Otherwise, the output has the same dimensions and layout as the input.
  626.    For instance, suppose you want to transform three-dimensional data of
  627. size `nx x ny x nz'.  Then, the current process will store a subset of
  628. this data, of size `local_nx x ny x nz', where the `x' indices
  629. correspond to the range `local_x_start' to `local_x_start+local_nx-1'
  630. in the "real" (i.e. logical) array.  If `fftwnd_mpi' is called with
  631. `FFTW_TRANSPOSED_ORDER' output, then the result will be a `ny x nx x
  632. nz' array, of which a `local_ny_after_transpose x nx x nz' subset is
  633. stored on the current process (corresponding to `y' values starting at
  634. `local_y_start_after_transpose').
  635.    The following is an example of allocating such a three-dimensional
  636. array array (`local_data') before the transform and initializing it to
  637. some function `f(x,y,z)':
  638.              fftwnd_mpi_local_sizes(plan, &local_nx, &local_x_start,
  639.                                     &local_ny_after_transpose,
  640.                                     &local_y_start_after_transpose,
  641.                                     &total_local_size);
  642.      
  643.              local_data = (fftw_complex*) malloc(sizeof(fftw_complex) *
  644.                                                  total_local_size);
  645.      
  646.              for (x = 0; x < local_nx; ++x)
  647.                      for (y = 0; y < ny; ++y)
  648.                              for (z = 0; z < nz; ++z)
  649.                                      local_data[(x*ny + y)*nz + z]
  650.                                              = f(x + local_x_start, y, z);
  651.    Some important things to remember:
  652.    * Although the local data is of dimensions `local_nx x ny x nz' in
  653.      the above example, do *not* allocate the array to be of size
  654.      `local_nx*ny*nz'.  Use `total_local_size' instead.
  655.    * The amount of data on each process will not necessarily be the
  656.      same; in fact, `local_nx' may even be zero for some processes.
  657.      (For example, suppose you are doing a `6x6' transform on four
  658.      processors.  There is no way to effectively use the fourth
  659.      processor in a slab decomposition, so we leave it empty.  Proof
  660.      left as an exercise for the reader.)
  661.    * All arrays are, of course, in row-major order (*note
  662.      Multi-dimensional Array Format::.).
  663.    * If you want to compute the inverse transform of the output of
  664.      `fftwnd_mpi', the dimensions of the inverse transform are given by
  665.      the dimensions of the output of the forward transform.  For
  666.      example, if you are using `FFTW_TRANSPOSED_ORDER' output in the
  667.      above example, then the inverse plan should be created with
  668.      dimensions `ny x nx x nz'.
  669.    * The data layout only depends upon the dimensions of the array, not
  670.      on the plan, so you are guaranteed that different plans for the
  671.      same size (or inverse plans) will use the same (consistent) data
  672.      layouts.
  673. File: fftw.info,  Node: Usage of MPI FFTW for Real Multi-dimensional Transforms,  Next: Usage of MPI FFTW for Complex One-dimensional Transforms,  Prev: MPI Data Layout,  Up: MPI FFTW
  674. Usage of MPI FFTW for Real Multi-dimensional Transforms
  675. -------------------------------------------------------
  676.    MPI transforms specialized for real data are also available,
  677. similiar to the uniprocessor `rfftwnd' transforms.  Just as in the
  678. uniprocessor case, the real-data MPI functions gain roughly a factor of
  679. two in speed (and save a factor of two in space) at the expense of more
  680. complicated data formats in the calling program.  Before reading this
  681. section, you should definitely understand how to call the uniprocessor
  682. `rfftwnd' functions and also the complex MPI FFTW functions.
  683.    The following is an example of a program using `rfftwnd_mpi'.  It
  684. computes the size `nx x ny x nz' transform of a real function
  685. `f(x,y,z)', multiplies the imaginary part by `2' for fun, then computes
  686. the inverse transform.  (We'll also use `FFTW_TRANSPOSED_ORDER' output
  687. for the transform, and additionally supply the optional workspace
  688. parameter to `rfftwnd_mpi', just to add a little spice.)
  689.      #include <rfftw_mpi.h>
  690.      
  691.      int main(int argc, char **argv)
  692.      {
  693.           const int nx = ..., ny = ..., nz = ...;
  694.           int local_nx, local_x_start, local_ny_after_transpose,
  695.               local_y_start_after_transpose, total_local_size;
  696.           int x, y, z;
  697.           rfftwnd_mpi_plan plan, iplan;
  698.           fftw_real *data, *work;
  699.           fftw_complex *cdata;
  700.      
  701.           MPI_Init(&argc,&argv);
  702.      
  703.           /* create the forward and backward plans: */
  704.           plan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD,
  705.                                          nx, ny, nz,
  706.                                          FFTW_REAL_TO_COMPLEX,
  707.                                          FFTW_ESTIMATE);
  708.           iplan = rfftw3d_mpi_create_plan(MPI_COMM_WORLD,
  709.            /* dim.'s of REAL data --> */  nx, ny, nz,
  710.                                           FFTW_COMPLEX_TO_REAL,
  711.                                           FFTW_ESTIMATE);
  712.      
  713.           rfftwnd_mpi_local_sizes(plan, &local_nx, &local_x_start,
  714.                                  &local_ny_after_transpose,
  715.                                  &local_y_start_after_transpose,
  716.                                  &total_local_size);
  717.      
  718.           data = (fftw_real*) malloc(sizeof(fftw_real) * total_local_size);
  719.      
  720.           /* workspace is the same size as the data: */
  721.           work = (fftw_real*) malloc(sizeof(fftw_real) * total_local_size);
  722.      
  723.           /* initialize data to f(x,y,z): */
  724.           for (x = 0; x < local_nx; ++x)
  725.                   for (y = 0; y < ny; ++y)
  726.                           for (z = 0; z < nz; ++z)
  727.                                   data[(x*ny + y) * (2*(nz/2+1)) + z]
  728.                                           = f(x + local_x_start, y, z);
  729.      
  730.           /* Now, compute the forward transform: */
  731.           rfftwnd_mpi(plan, 1, data, work, FFTW_TRANSPOSED_ORDER);
  732.      
  733.           /* the data is now complex, so typecast a pointer: */
  734.           cdata = (fftw_complex*) data;
  735.      
  736.           /* multiply imaginary part by 2, for fun:
  737.              (note that the data is transposed) */
  738.           for (y = 0; y < local_ny_after_transpose; ++y)
  739.                   for (x = 0; x < nx; ++x)
  740.                           for (z = 0; z < (nz/2+1); ++z)
  741.                                   cdata[(y*nx + x) * (nz/2+1) + z].im
  742.                                           *= 2.0;
  743.      
  744.           /* Finally, compute the inverse transform; the result
  745.              is transposed back to the original data layout: */
  746.           rfftwnd_mpi(iplan, 1, data, work, FFTW_TRANSPOSED_ORDER);
  747.      
  748.           free(data);
  749.           free(work);
  750.           rfftwnd_mpi_destroy_plan(plan);
  751.           rfftwnd_mpi_destroy_plan(iplan);
  752.           MPI_Finalize();
  753.      }
  754.    There's a lot of stuff in this example, but it's all just what you
  755. would have guessed, right?  We replaced all the `fftwnd_mpi*' functions
  756. by `rfftwnd_mpi*', but otherwise the parameters were pretty much the
  757. same.  The data layout distributed among the processes just like for
  758. the complex transforms (*note MPI Data Layout::.), but in addition the
  759. final dimension is padded just like it is for the uniprocessor in-place
  760. real transforms (*note Array Dimensions for Real Multi-dimensional
  761. Transforms::.).  In particular, the `z' dimension of the real input
  762. data is padded to a size `2*(nz/2+1)', and after the transform it
  763. contains `nz/2+1' complex values.
  764.    Some other important things to know about the real MPI transforms:
  765.    * As for the uniprocessor `rfftwnd_create_plan', the dimensions
  766.      passed for the `FFTW_COMPLEX_TO_REAL' plan are those of the *real*
  767.      data.  In particular, even when `FFTW_TRANSPOSED_ORDER' is used as
  768.      in this case, the dimensions are those of the (untransposed) real
  769.      output, not the (transposed) complex input.  (For the complex MPI
  770.      transforms, on the other hand, the dimensions are always those of
  771.      the input array.)
  772.    * The output ordering of the transform (`FFTW_TRANSPOSED_ORDER' or
  773.      `FFTW_TRANSPOSED_ORDER') *must* be the same for both forward and
  774.      backward transforms.  (This is not required in the complex case.)
  775.    * `total_local_size' is the required size in `fftw_real' values, not
  776.      `fftw_complex' values as it is for the complex transforms.
  777.    * `local_ny_after_transpose' and `local_y_start_after_transpose'
  778.      describe the portion of the array after the transform; that is,
  779.      they are indices in the complex array for an
  780.      `FFTW_REAL_TO_COMPLEX' transform and in the real array for an
  781.      `FFTW_COMPLEX_TO_REAL' transform.
  782.    * `rfftwnd_mpi' always expects `fftw_real*' array arguments, but of
  783.      course these pointers can refer to either real or complex arrays,
  784.      depending upon which side of the transform you are on.  Just as for
  785.      in-place uniprocessor real transforms (and also in the example
  786.      above), this is most easily handled by typecasting to a complex
  787.      pointer when handling the complex data.
  788.    * As with the complex transforms, there are also
  789.      `rfftwnd_create_plan' and `rfftw2d_create_plan' functions, and any
  790.      rank greater than one is supported.
  791.    Programs using the MPI FFTW real transforms should link with
  792. `-lrfftw_mpi -lfftw_mpi -lrfftw -lfftw -lm' on Unix.
  793. File: fftw.info,  Node: Usage of MPI FFTW for Complex One-dimensional Transforms,  Next: MPI Tips,  Prev: Usage of MPI FFTW for Real Multi-dimensional Transforms,  Up: MPI FFTW
  794. Usage of MPI FFTW for Complex One-dimensional Transforms
  795. --------------------------------------------------------
  796.    The MPI FFTW also includes routines for parallel one-dimensional
  797. transforms of complex data (only).  Although the speedup is generally
  798. worse than it is for the multi-dimensional routines,(1) these
  799. distributed-memory one-dimensional transforms are especially useful for
  800. performing one-dimensional transforms that don't fit into the memory of
  801. a single machine.
  802.    The usage of these routines is straightforward, and is similar to
  803. that of the multi-dimensional MPI transform functions.  You first
  804. include the header `<fftw_mpi.h>' and then create a plan by calling:
  805.      fftw_mpi_plan fftw_mpi_create_plan(MPI_Comm comm, int n,
  806.                                         fftw_direction dir, int flags);
  807.    The last three arguments are the same as for `fftw_create_plan'
  808. (except that all MPI transforms are automatically `FFTW_IN_PLACE').
  809. The first argument specifies the group of processes you are using, and
  810. is usually `MPI_COMM_WORLD' (all processes).  A plan can be used for
  811. many transforms of the same size, and is destroyed when you are done
  812. with it by calling `fftw_mpi_destroy_plan(plan)'.
  813.    If you don't care about the ordering of the input or output data of
  814. the transform, you can include `FFTW_SCRAMBLED_INPUT' and/or
  815. `FFTW_SCRAMBLED_OUTPUT' in the `flags'.  These save some communications
  816. at the expense of having the input and/or output reordered in an
  817. undocumented way.  For example, if you are performing an FFT-based
  818. convolution, you might use `FFTW_SCRAMBLED_OUTPUT' for the forward
  819. transform and `FFTW_SCRAMBLED_INPUT' for the inverse transform.
  820.    The transform itself is computed by:
  821.      void fftw_mpi(fftw_mpi_plan p, int n_fields,
  822.                    fftw_complex *local_data, fftw_complex *work);
  823.    `n_fields', as in `fftwnd_mpi', is equivalent to `howmany=n_fields',
  824. `stride=n_fields', and `dist=1', and should be `1' when you are
  825. computing the transform of a single array.  `local_data' contains the
  826. portion of the array local to the current process, described below.
  827. `work' is either `NULL' or an array exactly the same size as
  828. `local_data'; in the latter case, FFTW can use the `MPI_Alltoall'
  829. communications primitive which is (usually) faster at the expense of
  830. extra storage.  Upon return, `local_data' contains the portion of the
  831. output local to the current process (see below).
  832.    To find out what portion of the array is stored local to the current
  833. process, you call the following routine:
  834.      void fftw_mpi_local_sizes(fftw_mpi_plan p,
  835.                                int *local_n, int *local_start,
  836.                                int *local_n_after_transform,
  837.                                int *local_start_after_transform,
  838.                                int *total_local_size);
  839.    `total_local_size' is the number of `fftw_complex' elements you
  840. should actually allocate for `local_data' (and `work').  `local_n' and
  841. `local_start' indicate that the current process stores `local_n'
  842. elements corresponding to the indices `local_start' to
  843. `local_start+local_n-1' in the "real" array.  *After the transform, the
  844. process may store a different portion of the array.*  The portion of
  845. the data stored on the process after the transform is given by
  846. `local_n_after_transform' and `local_start_after_transform'.  This data
  847. is exactly the same as a contiguous segment of the corresponding
  848. uniprocessor transform output (i.e. an in-order sequence of sequential
  849. frequency bins).
  850.    Note that, if you compute both a forward and a backward transform of
  851. the same size, the local sizes are guaranteed to be consistent.  That
  852. is, the local size after the forward transform will be the same as the
  853. local size before the backward transform, and vice versa.
  854.    Programs using the FFTW MPI routines should be linked with
  855. `-lfftw_mpi -lfftw -lm' on Unix, in addition to whatever libraries are
  856. required for MPI.
  857.    ---------- Footnotes ----------
  858.    (1) The 1D transforms require much more communication.  All the
  859. communication in our FFT routines takes the form of an all-to-all
  860. communication: the multi-dimensional transforms require two all-to-all
  861. communications (or one, if you use `FFTW_TRANSPOSED_ORDER'), while the
  862. one-dimensional transforms require *three* (or two, if you use
  863. scrambled input or output).
  864.